# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=git-warp-time
pkgver=0.7.2
pkgrel=0
pkgdesc="Reset timestamps of Git repository files to the time of the last modifying commit"
url="https://github.com/alerque/git-warp-time"
license="GPL-3.0-only"
arch="all"
makedepends="cargo cargo-auditable"
subpackages="$pkgname-bash-completion $pkgname-fish-completion $pkgname-zsh-completion"
options="net"
source="https://github.com/alerque/git-warp-time/archive/v$pkgver/git-warp-time-$pkgver.tar.gz"

prepare() {
	default_prepare

	# Doc-tests from README.md expect to be ran in a Git repository
	git init -q .
	git config --local user.name "example"
	git config --local user.email "example@example.com"
	git add .
	git commit -q -m "init"

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --frozen --release
}

check() {
	cargo test --frozen
}

package() {
	install -Dm755 target/release/$pkgname -t "$pkgdir"/usr/bin/

	# shell completions
	find target/release -name $pkgname.bash \
		-exec install -Dm644 {} "$pkgdir"/usr/share/bash-completion/completions/$pkgname \;
	find target/release -name $pkgname.fish \
		-exec install -Dm644 {} "$pkgdir"/usr/share/fish/vendor_completions.d/$pkgname.fish \;
	find target/release -name _$pkgname \
		-exec install -Dm644 {} "$pkgdir"/usr/share/zsh/site-functions/_$pkgname \;
}

sha512sums="
250230aef6ad74decaabbaf7f757a5abea44f2d5bbf4c240273244dfc84395c47d31af27a7dedecacda206e44805a6023cca9d770e1e2e4485d34901d8a4c8f9  git-warp-time-0.7.2.tar.gz
"
